package utils

import (
	"crypto/md5"
	"fmt"
	"math/rand"
	"strconv"
	"time"
)

func CreateRandStr(str string, prefix string) string {
	//获取当前时间戳
	now := time.Now()
	timestamp := now.Unix()
	//随机数
	randomNum := rand.Int()
	//拼接
	str = str + strconv.Itoa(randomNum) + strconv.FormatInt(timestamp, 10)
	//MD5加密
	data := []byte(str)
	has := md5.Sum(data)
	md5str := prefix + fmt.Sprintf("%x", has) //将[]byte转成16进制
	return md5str
}
